<?php
	include("conn.php");

	mysql_query("delete from ui_datagrid");
	if ($fh = fopen('./data.txt','r')) {
		$count = 0;
		while (!feof($fh)) {
			$line = fgets($fh);
			$arr = (explode(',', $line));
			$sql = "insert into `ui_datagrid` (`code`,`company`,`name`,`areacode`) values('$arr[0]','$arr[1]','$arr[2]','".rtrim($arr[3])."')";
			echo 'exec-sql:'.$sql.'<br/>';
			$count += mysql_query($sql);
		}
		echo 'execute complete! insert rows : '.$count;
		fclose($fh);
	}
?>